package com.njtoyo.taxi.admin.rest.controller.local_service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.local_service.OrderDetailsPresenter;
import com.njtoyo.taxi.admin.rest.presenter.local_service.OrderPagePresenter;
import com.njtoyo.taxi.admin.rest.wrapper.local_service.order.OrderPageWrapper;
import com.njtoyo.taxi.admin.service.local_service.LifeOrderService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

@RestController
@Api(value = "订单管理", tags = "订单管理")
@RequestMapping("local-service/order")
public class OrderController {

    @Autowired
    private LifeOrderService lifeOrderService;

    @GetMapping("")
    @ApiOperation(value = "订单列表", notes = "订单列表,权限：life_order_list")
    @PermissionScope(names = {"life_order_list"})
    RestResult<Page<OrderPagePresenter>> getPage(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser,
                                                 @Valid OrderPageWrapper wrapper) {
        return lifeOrderService.getPage(adminUser, wrapper);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "订单详情", notes = "订单详情,权限:life_order_list")
    @PermissionScope(names = {"life_order_list"})
    RestResult<OrderDetailsPresenter> details(@PathVariable("id") Long id) {
        return lifeOrderService.details(id);
    }

}
